package main.java.study.step02;

/**
 * @author liuwenxiu
 * @Description: 静态代码块demo
 * @date 2022-7-13 15:14
 */
public class StaticCodeBlockDemo {
    private static String name;
    private Integer age;
    // 静态代码块
    static {
        name = "sakura";
        System.out.println("我是静态代码块");
    }
    // 构造方法
    public StaticCodeBlockDemo() {
        System.out.println("我是构造方法");
    }
    // 构造代码块
    {
        name = "tom";
        age = 21;
        System.out.println("我是构造代码块");
    }
    public void test(){
        // 局部代码块
        {
            System.out.println("我是局部代码块");
        }
    }

    public static void main(String[] args) {
        StaticCodeBlockDemo demo = new StaticCodeBlockDemo();
        demo.test();
    }
}
